layui.use(['table','form','element'], function(){
    var table = layui.table;
    var form = layui.form;
    var element = layui.element;
    var layer = layui.layer;

    var $ = layui.$;

    form.on('submit(formDemo)', function (data) {
        $.ajax({
            url: serverUrl +"/sys/resource/add",
            data: data.field,
            type: 'post',
            dataType: 'json',
            success: function (result) {
                if(result.code=='200') {
                    location.href='list.html';
                } else {
                    layer.msg(result.msg);
                }
            },
            error: function (xhr) {
                console.log(xhr);
                layer.msg('出错了');
            }
        })
        return false;
    });
});
